packages
test several options and choose optimal perplexity in: data, perplexities out: plots
library(Rtsne) library(ggplot2) find_optimal_p_tSNE <- function(perplexities, data) { for (p in perplexities) { tsne_out <- Rtsne(as.matrix(train), perplexity = p) plot(tsne_out$Y) } }
in: ion data optimal perplexity out: (x,y) coordinates
run_tSNE <- function(data, optimal_p) { all_tsne_out <- Rtsne(as.matrix(data), perplexity = optimal_p) tsne_coords <- as.data.frame(all_tsne_out$Y) return(tsne_coords) }
in: ion data out: (x,y) coordinates
run_PCA <- function(data) { res <- prcomp(data)$x return(res[,c(1,2)]) }
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.